<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			*{
			    margin: 0;
			    padding: 0;
			}
			
			#box{
			    width: 100px;
			    height: 100px;
			    background-color: red;
			
			    position: absolute;
			}
		</style>
	</head>
	<body>
		<button id="btn">往右走</button>
		<div id="box"></div>
		
		<script src="../../通用兼容文件.js"></script>
		<script> 
		window.onload = function(){
			var end = 600; timer =null;
			var box = $('box');
			
			$('btn').onclick = function(){
			clearInterval(timer);
				
				timer = setInterval(function(){
				var speed = (end-box.offsetLeft)*0.2;
				
				
				 console.log("之前" + speed);
				speed = Math.ceil(speed);
				 console.log("之后" + speed);	
				  
				box.style.left = box.offsetLeft +speed +'px';
				box.innerText = box.offsetLeft;	
				
				
				
				if(box.offsetLeft === end){
				    clearInterval(timer);
				}	
				},200);
				
				
				
				
				
			}
			
			
			
			
			
			
		}
		
		
		
		</script>
	</body>
</html>
